package lib.bone.access.validator;


import lib.bone.access.constant.WorkloadTypeConst;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class IsWorkloadTypeValidator implements ConstraintValidator<IsWorkloadType, Object> {
    @Override
    public void initialize(IsWorkloadType constraintAnnotation) {
        ConstraintValidator.super.initialize(constraintAnnotation);
    }

    @Override
    public boolean isValid(Object o, ConstraintValidatorContext constraintValidatorContext) {
        String type = o.toString();
        if (type.equals(WorkloadTypeConst.RESEARCH) || type.equals(WorkloadTypeConst.TEACH) || type.equals(WorkloadTypeConst.MANAGEMENT) || type.equals(WorkloadTypeConst.PART_TIME)){
            return true;
        }
        return false;
    }
}
